from app import models
from django import forms
from app.forms.account import BootstrapForm

class WikiModelForm(BootstrapForm,forms.ModelForm):
    class Meta:
        model = models.Wiki
        exclude = ['project','depth']

    def __init__(self,request, *args,**kwargs):
        super().__init__(*args,**kwargs)
        self.request = request
        #获取当前项目的所有wiki目录
        total_list = [('','请选择'),]
        data_list = models.Wiki.objects.filter(project=self.request.tracer.project).values_list('id','title')
        total_list.extend(data_list)
        self.fields['parent'].choices = total_list
